package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package")
load("//:packages.bzl", "VERSION_PLACEHOLDER_REPLACEMENTS")
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library")

filegroup(
  name = "schematics_assets",
  srcs = glob(["ng-generate/*/files/**/*", "**/*.json"]),
)

ts_library(
  name = "schematics",
  module_name = "@angular/material/schematics",
  srcs = glob(["**/*.ts"], exclude=[
    "**/*.spec.ts",
    "ng-update/test-cases/**/*.ts",
    "ng-generate/*/files/**/*.ts",
  ]),
  deps = [
    "//src/cdk/schematics",
    "@matdeps//@angular-devkit/schematics",
    "@matdeps//@schematics/angular",
    # TODO(devversion): Only include jasmine for test sources (See: tsconfig types).
    "@matdeps//@types/jasmine",
    "@matdeps//@types/node",
    "@matdeps//tslint",
    "@matdeps//typescript",
  ],
  tsconfig = ":tsconfig.json",
)

# This package is intended to be combined into the main @angular/material package as a dep.
npm_package(
  name = "npm_package",
  srcs = [":schematics_assets"],
  deps = [":schematics"],
  replacements = VERSION_PLACEHOLDER_REPLACEMENTS,
)

### Testing rules

jasmine_node_test(
  name = "unit_tests",
  srcs = [":schematics_test_sources"],
  data = [":schematics_assets", ":schematics_test_cases"],
)

ts_library(
  name = "schematics_test_sources",
  srcs = glob(["**/*.spec.ts"], exclude=["ng-generate/*/files/**/*.spec.ts"]),
  deps = [
    ":schematics",
    "//src/cdk/schematics",
    "//src/cdk/schematics/testing",
    "@matdeps//@schematics/angular",
    "@matdeps//@angular-devkit/schematics",
    "@matdeps//@types/jasmine",
    "@matdeps//@types/node",
  ],
  tsconfig = ":tsconfig.json",
  testonly = True,
)

filegroup(
  name = "schematics_test_cases",
  srcs = glob([
    "ng-update/test-cases/**/*_input.ts",
    "ng-update/test-cases/**/*_expected_output.ts"
  ]),
  testonly = True,
)
